# -*- coding: utf-8 -*-
# @Time    : 2022/11/11
# @Author  : paulin

from basic.device.Android import Android

class allAppPage(Android):
    #应用展台
    appShowCase = "com.cloudbae.lovenanning:id/group_app_recycler"
    #应用名称
    appName = "com.cloudbae.lovenanning:id/apply_name"
    #保存按钮
    saveBtn = "com.cloudbae.lovenanning:id/edit_save"
    #返回按钮
    backBtn = "com.cloudbae.lovenanning:id/tvBack"
    #删除、增加应用图标
    editIcon = "com.cloudbae.lovenanning:id/apply_edit_state_icon"

    @classmethod
    def getGroupApp(cls):
        appList = cls.poco(cls.appShowCase).child(type="android.widget.FrameLayout").offspring(cls.appName)
        appListName = []
        for i in range(0, len(appList)):
            appListName.append(appList[i].get_text())
        print("我的应用展台下第一个展台应用：", appListName)
        return appListName

    @classmethod
    def editApp(cls,appName):
        cls.poco(text=appName).sibling(cls.editIcon).click()
        print("添加或删除应用")

    @classmethod
    def save(cls):
        cls.poco(cls.saveBtn).click()
        print("点击保存按钮")

    @classmethod
    def clickBack(cls):
        cls.poco(cls.backBtn).click()
        print("点击返回")